<?php
class Loader{
    private static $_config;

    // 自动加载model
    public static function loadModel($class,$dir='',$suffix=".class.php"){
        $class_path = __ROOT__."model/".$dir.$class.$suffix;
        if(is_readable($class_path)){
            require_once $class_path;
        }
    }
    
    // 自动加载配置文件
    public static function loadCfg($type,$dir='',$suffix=".inc.php"){
        $config_file_path = __ROOT__."config/".$dir.$type.$suffix;
        if(is_readable($config_file_path)){
            self::$_config[$config_file_path] = include $config_file_path;
        }
        return self::$_config[$config_file_path];
    }
    
    // 自动加载lib文件
    public static function loadLib($type,$dir='',$suffix=".class.php"){
        $config_file_path = __SYS__."lib/".$dir.$type.$suffix;
        if(is_readable($config_file_path)){
            require_once $config_file_path;
        }
    }
    
}

